//
//  ViewController.m
//  YHLoopScrollView
//
//  Created by cunli.cn on 15/10/12.
//  Copyright © 2015年 cunli.cn. All rights reserved.
//

#import "ViewController.h"
#import "YHLoopScrollView.h"
@interface ViewController ()<YHLoopScrollViewDelegate>
@property (strong, nonatomic)YHLoopScrollView *loopScrollView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self.view addSubview:self.loopScrollView];
    [self loadLoopData];
}

-(YHLoopScrollView *)loopScrollView
{
    if (_loopScrollView == nil) {
        _loopScrollView = [[YHLoopScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 135)];
        _loopScrollView.yhLoopScrollViewDelegate = self;
    }
    return _loopScrollView;
}

-(void)loadLoopData
{
    //加载轮播图数据，这里你可以请求你自己的服务器，获取数据列表，这里我写死了url数组，你视你的需求而定
    NSArray *images = @[@"http://img2.3lian.com/2014/f7/5/d/22.jpg", @"http://pic1.nipic.com/2009-02-20/2009220135032130_2.jpg", @"http://img6.faloo.com/Picture/0x0/0/747/747488.jpg",
        @"http://imgsrc.baidu.com/forum/pic/item/09be3f094b36acaf0ad6eb717cd98d1000e99cde.jpg"];
    self.loopScrollView.imagesGroup = [NSMutableArray arrayWithArray:images];
}

#pragma mark - YHLoopScrollViewDelegate
-(void)yhLoopScrollView:(UIScrollView *)loopScrollView didSelectWithIndex:(NSInteger)index
{
    //选中某张轮播图触发的方法，索引从1开始
    NSLog(@"index:%ld",(long)index);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
